/*
 * File:   Step2.h
 * Author: jcrada
 *
 * Created on 28 April 2011, 5:23 PM
 */

#ifndef ECB_STEP2_H
#define	ECB_STEP2_H

#include "ecb/base/Problem.h"

namespace ecb {

    /* Source:
   @book{bf:qings-book,
        author = {Qing, Anyong},
        title = {Differential Evolution: Fundamentals and Applications in Electrical Engineering},
        year = {2009},
        publisher = {Wiley-IEEE Press}}
     */
    class Step2 : public Problem {
    public:

        Step2(const std::string& id = "Step2", const std::string& name = "Step2",
                int dimensions = 0, scalar minimum = -500, scalar maximum = 500,
                bool minimization = true) :
        Problem(id, name, dimensions, minimum, maximum, minimization) { }

        scalar f(const std::vector<scalar>& x) {
            scalar result = 0;
            for (size_t i = 0; i < x.size(); ++i) {
                result += std::floor(x[i] + 0.5) * std::floor(x[i] + 0.5);
            }
            return result;
        }
    };
}

#endif	/* ECB_STEP2_H */

